list      p=16F84A                  ;dfinition de processeur
#include <p16F84A.inc>              ;dfinition des constantes
__CONFIG  _CP_OFF & _WDT_OFF & _PWRTE_ON & _HS_OSC  ;configuration
;------------------------------------------------------------------
        CBLOCK 0x0c                     ;resarvation RAM
        xu:1	;unit
	xd:1	;dizaine
	x:1
        ENDC
;------------------------------------------------------------
        org     0                         ;debut
        goto    dd 
;------------------------------------------------------------
        org     4                         ;Interuption
        
	btfss	INTCON,INTF
	goto	d1
	decf	xu,F	;decremente les units
	movlw	d'0'
	subwf	xu,W
	btfss	STATUS,Z
	goto	d1

	clrf	xu
	movlw	d'9'
	movwf	xu
	decf	xd,F	;decremente les dizaines
	movlw	d'0'
	subwf	xd,W
	btfss	STATUS,Z
	goto	d1

	clrf	xd
	movlw	d'9'
	movwf	xd

d1	bcf	INTCON,INTF
	retfie
;-----------------------------------------------------------
dd	clrf	xu
	movlw	0x90
	movwf	xu
	clrf	xd
	movlw	d'9'
	movwf	xd
	bsf	STATUS,RP0
	clrf	TRISA
	movlw	b'00000001'
	movwf	TRISB
	bcf	STATUS,RP0

	bsf	INTCON,GIE
	bsf	STATUS,RP0
	bsf	INTCON,INTE
	bcf	STATUS,RP0
	bsf	OPTION_REG,INTEDG

d2	movf	xd,W
	movwf	PORTA
	movf	xu,W

	movwf	PORTB
	
	goto	d2
	end
